package io.imgselector;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;


import java.util.ArrayList;

import takephoto.activity.TakePicActivity;

public class TActivity extends TakePicActivity  {
    private String isEdit="0";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        String type=getIntent().getStringExtra("type");
        String adress=getIntent().getStringExtra("adress");
        isEdit=  getIntent().getStringExtra("isEdit");
        if ("0".equals(type)){
            takePhoto(false,adress);
        }else {
            pickPhoto(getIntent().getIntExtra("count",0),false);
        }

    }

    @Override
    public void upLoadFile(ArrayList<String> filePath) {
        super.upLoadFile(filePath);

//        Toast.makeText(this, ""+filePath.toString(), Toast.LENGTH_SHORT).show();
//        Intent intent=new Intent();
//        intent.putStringArrayListExtra("file",filePath);
//        setResult(10123,intent);



        if(FlutterNativeImgPlugin.result!=null){
            FlutterNativeImgPlugin.result.success(filePath);
        }

        try {

//            if ("1".equals(isEdit)&&filePath!=null&&filePath.size()>0){
//                Intent intent=new Intent(TActivity.this,PhotoCanvasActivity.class);
//                intent.putExtra("path",filePath.get(0));
//                startActivity(intent);
//            }

//            H5Service h5Service = MPFramework.getExternalService(H5Service.class.getName());
//            final H5Page h5Page = h5Service.getTopH5Page();
//            Log.e("sss::",h5Page.toString());
//            if (null != h5Page) {
//                JSONObject jo = new JSONObject();
//                jo.put("key",filePath.get(0));
//                // native 向小程序发送事件的方法
//                // 第一个是事件名称，第二个是参数，第三个默认传 null
//                h5Page.getBridge().sendDataWarpToWeb("nativeToTiny", jo, null);
//            }
        }catch (Exception e){

        }

        finish();
    }
/* public void doClick(View v) {
        pickPhoto();
    }*/
}
